<%@ page language="java" contentType="text/html; charset=utf-8 " pageEncoding="utf-8" import="domain.Visitors,service.visitor.*,domain.Room" %>
<html>
	<head>
		<meta charset="utf-8">
		<base href="<%=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/" %>"/>
		<meta name="viewport" content="width=drvice-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
		<title>修改信息</title>
    </head>
    <link href="css/common.css" rel="stylesheet" type="text/css" />
            <script type="text/javascript" src="js/jquery-1.9.1.js"></script>
            <script type="text/javascript" src="js/date.js"></script>
            <script type="text/javascript" src="js/iscroll.js"></script>
            <script type="text/javascript">
                $(function() {
                    $('#cometime').date();
                });
    function messageLoad(){
        		var message = '<%=request.getAttribute("message") %>';
        		if(message != 'null'){
        			alert(message);
        		}
        	}
                    	function beforeSubmit(){
                        if(document.getElementById('name').value==''){
                        alert('姓名不能为空！');
                        document.getElementById('name').focus();
                        return false;
                        }
                        if(document.getElementById('validtime').value=='0'){
                        alert('未选择时效');
                        document.getElementById('validtime').focus();
                        return false;
                        }
                        if(document.getElementById('phone').value==''){
                        alert('手机不能为空！');
                        document.getElementById('phone').focus();
                        return false;
                        }
                        if(document.getElementById('idcard').value==''){
                        alert('身份证号不能为空！');
                        document.getElementById('idcard').focus();
                        return false;
                        }
                        if(document.getElementById('cometime').value==''){
                        alert('到访时间不能为空！');
                        document.getElementById('cometime').focus();
                        return false;
                        }
                        if(document.getElementById('reason').value==''){
                        alert('到访原因不能为空！');
                        document.getElementById('reason').focus();
                        return false;
                        }
                        }
    </script>
	<style type="text/css">
		body{padding:0px;margin:0px;}
		.bgdiv{
			background:url(image/background.png) no-repeat;
			position: fixed;
			width: 100%;
			height: 100%;
			background-size:100% 100%;
		}
		.registeredbox{
			margin: auto;
			width: 80%;
			height: 100%;
			border-radius: 10px;
			box-shadow: rgba(0, 0, 0, 0.08) 1px 2px 4px 0px;
			background-color: white;
			opacity: 0.6;
			text-align: center;
			overflow:auto;
		}
		.title{
			padding-top: 20px;
			font-weight: 600;
		}
		button{
			border-width: 0px;
			    width: 70px;
			    height: 25px;
			    background: inherit;
			    background-color: rgba(0, 207, 226, 1);
			    border: none;
			    border-radius: 50px;
			    -moz-box-shadow: none;
			    -webkit-box-shadow: none;
			    box-shadow: none;
			    font-size: 14px;
			    color: #FFFFFF;
				margin-top: 5px;
		}
		input{
						width: 100%;
						height: 6px;
		                border: 1px solid #ccc;
		                padding: 7px 0px;
		                border-radius: 3px;
		                padding-left:5px;
		                -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
		                box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
		                -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
		                -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
		                transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s
		            }
		            input:focus{
		                    border-color: #66afe9;
		                    outline: 0;
		                    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);
		                    box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)
		            }
					.loginform{
						margin: auto;
						width: 80%;
						padding-top: 20px;
						text-align: left;
						font-size: 12px;
						font-weight: 700;
					}
	</style>
	<%
                                        	Room room=new Room();
                                        	if(session.getAttribute("userloginflag")==null){
                                        	%>
                                        	<script type="text/javascript">
                                        	    window.location.href="index.jsp";
                                        	</script>
                                            <% }else{
                                            room=(Room)session.getAttribute("userloginflag");
                                            %>
	<body onload="messageLoad()">
		<div class="bgdiv"></div>
			<div class="registeredbox">
				<div class="title">修改信息</div>
				<div class="loginform">
				<%          int i = Integer.parseInt(request.getParameter("visitors_id"));
                				            VisitorService visitorService = new VisitorServiceImpl();
                				            Visitors info = visitorService.seeInfo(i);
                %>
				<form action="UpdateVisitor?visitors_id=<%=info.getVisitors_id() %>" method="post"  enctype="multipart/form-data"  onsubmit="return beforeSubmit(this)" >
					姓名<font style="color: red;">*</font><span id="info"></span><br />
					<input type="text" name="name" id="name" readonly="readonly" value="<%=info.getName() %>"  /><br />
					<span style="font-size: 8px;font-weight: 200;color: #555555;">访客姓名</span><br /><br />

					手机<font style="color: red;">*</font>
					<input type="text" name="phone" id="phone" value="<%=info.getPhone() %>"  /><br />
					<span style="font-size: 8px;font-weight: 200;color: #555555;">访客的有效联系方式</span><br /><br />

					车牌<font style="color: red;"></font>
					<input type="text" name="carid" id="carid" value="<%=info.getCarid() %>"  /><br />
					<span style="font-size: 8px;font-weight: 200;color: #555555;">访客车牌，可不填</span><br /><br />

					身份证号<font style="color: red;">*</font><br />
					<input type="text" name="idcard" id="idcard" value="<%=info.getIdcard() %>"  /><br />
					<span style="font-size: 8px;font-weight: 200;color: #555555;">访客的身份证号</span><br /><br />

					到访时间<font style="color: red;">*</font><br />
					<input readonly="readonly" type="text" name="cometime" id="cometime"  value="<%=info.getCometime() %>"/><br />
					<span style="font-size: 8px;font-weight: 200;color: #555555;">访客的到访时间</span><br /><br />

                    时效<font style="color: red;" >*</font><br />
					<select id="validtime" name="validtime" style="width:80%">
					<option value="0">请选择</option>
					<% for(int j=1;j<=24;j++){ %>
					<option value="<%= j %>"><%=j %>小时</option><% } %>
					</select>
					<br />
					<span style="font-size: 8px;font-weight: 200;color: #555555;">访客的到访当日到访时效从0时开始，最长24小时</span><br /><br />

					到访原因<font style="color: red;">*</font><br />
                    <input type="text" name="reason" id="reason" value="<%=info.getReason() %>"  /><br />
                    <span style="font-size: 8px;font-weight: 200;color: #555555;">访客的到访原因</span><br /><br />

					个人免冠照片<font style="color: red;">*</font><br />
					<span style="font-size: 8px;font-weight: 200;color: #555555;">必须为本人近期正面免冠彩色头像，头部长度占照片长度的2/3，不着制式服装或白色上衣，常带眼镜的应佩戴眼镜</span><br />
					<input type="file" id="identity_img1" name="identity_img1" onchange='PreviewImage1(this)' style="height:30px ;"  /><br />
					<div id="imgPreview1" style="position: relative;left: 8%;margin-top: 10px;"><img src="<%=info.getPhoto_img() %>" width="100px"  /></div><br /><br />

					<center><button type="submit" id="submit">修改</button></center>
				</form>
				</div>
			</div>
			<div id="datePlugin">
                    </div>
	</body><% } %>
	<script>
	    if(/Android (\d+\.\d+)/.test(navigator.userAgent)){
	       var version = parseFloat(RegExp.$1);
	    if(version>2.3){
	       var phoneScale = parseInt(window.screen.width)/230;
	       document.write('<meta name="viewport" content="width=230, minimum-scale = '+ phoneScale +', maximum-scale = '+ phoneScale +', user-scalable=no, target-densitydpi=device-dpi">');
	       }else{
	            document.write('<meta name="viewport" content="width=230, target-densitydpi=device-dpi">');
	       }
	       }else{
	            document.write('<meta name="viewport" content="width=230, user-scalable=no, target-densitydpi=device-dpi">');
	       }
		   function PreviewImage1(imgFile)
			{
				var pattern = /(\.*.jpg$)|(\.*.png$)|(\.*.jpeg$)|(\.*.gif$)|(\.*.bmp$)/;
				if(!pattern.test(imgFile.value))
				{
					alert("系统仅支持jpg/jpeg/png/gif/bmp格式的照片！");
					imgFile.focus();
				}
				else
				{
					var path;
					if(document.all)//IE
					{
						imgFile.select();
						path = document.selection.createRange().text;
						document.getElementById("imgPreview1").innerHTML="";
						document.getElementById("imgPreview1").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='scale',src=\"" + path + "\")";//使用滤镜效果
					}
					else//FF
					{
						path = URL.createObjectURL(imgFile.files[0]);
						document.getElementById("imgPreview1").innerHTML = "<img src='"+path+"' width='100px'/>";
					}
				}
			}
	</script>
</html>